
// Copyright (c) 2002 HTHK
package admin.system.role;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.servlet.*;
import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;
import com.ffpc.util.*;
/**
 * A Class class.
 * <P>
 * @author HTHK
 */
public class RoleServlet
  extends DBServlet {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      String action = new String(request.getParameter("formAction"));
      RoleBean role = RoleProcess.createBean();
      role.setRole_id(request.getParameter("role_id"));
      role.setRole_name(request.getParameter("role_name"));
      role.setRole_des(request.getParameter("role_des"));
      role.setUpd_user(getUser().getUser_id());
      role.setUpd_date(DateFormatter.format(this.getDate()));
      if (action.trim().equalsIgnoreCase("Create"))
      {
         role.setCrt_user(getUser().getUser_id());
         role.setCrt_date(DateFormatter.format(this.getDate()));
        if (RoleProcess.insert(this.getConnection(),role)>0)
            message.setMessage("Save successfully.");
        else
            message.setMessage("Save failure");
      }
      else if (action.trim().equalsIgnoreCase("Update"))
        if (RoleProcess.update(this.getConnection(),role)>0)
            message.setMessage("Save successfully.");
        else
            message.setMessage("Save failure.");
      else if (action.trim().equalsIgnoreCase("Delete"))
        if (RoleProcess.delete(this.getConnection(),role)>0)
            message.setMessage("Delete successfully.");
        else
            message.setMessage("Delete failure.");
      else
            message.setMessage("No action mapped!");
      return "system/RoleSearch.jsp";
  }
}


